//// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
//package com.linqingying.gitcode.pullrequest.ui.toolwindow.model
//
//import com.intellij.collaboration.async.cancelledWith
//import com.intellij.collaboration.ui.toolwindow.ReviewTabViewModel
//import com.intellij.openapi.Disposable
//import com.intellij.openapi.components.service
//import com.intellij.openapi.project.Project
//import com.intellij.platform.util.coroutines.childScope
//import git4idea.remote.hosting.knownRepositories
//import kotlinx.coroutines.CoroutineScope
//import kotlinx.coroutines.cancel
//import kotlinx.coroutines.channels.Channel
//import kotlinx.coroutines.flow.Flow
//import kotlinx.coroutines.flow.receiveAsFlow
//import org.jetbrains.annotations.ApiStatus
//import com.linqingying.gitcode.i18n.GitCodeBundle
//import com.linqingying.gitcode.pullrequest.data.GCPRDataContext
//import com.linqingying.gitcode.pullrequest.data.GCPRIdentifier
//import com.linqingying.gitcode.ui.util.GCUIUtil
//import com.linqingying.gitcode.util.GCHostedRepositoriesManager
//
//@ApiStatus.Experimental
//sealed interface GCPRToolWindowTabViewModel : ReviewTabViewModel {
//  @ApiStatus.Experimental
//  class PullRequest internal constructor(parentCs: CoroutineScope,
//                                         projectVm: GCPRToolWindowProjectViewModel,
//                                         id: GCPRIdentifier)
//    : GCPRToolWindowTabViewModel, Disposable {
//    private val cs = parentCs.childScope().cancelledWith(this)
//
//    override val displayName: String = "#${id.number}"
//
//    val infoVm: GCPRInfoViewModel = projectVm.acquireInfoViewModel(id, this)
//    private val _focusRequests = Channel<Unit>(1)
//    internal val focusRequests: Flow<Unit> = _focusRequests.receiveAsFlow()
//
//    fun requestFocus() {
//      _focusRequests.trySend(Unit)
//    }
//
//    fun selectCommit(oid: String) {
//      infoVm.detailsVm.value.result?.getOrNull()?.changesVm?.selectCommit(oid)
//    }
//
//    override fun dispose() {
//      cs.cancel()
//    }
//  }
//
//  @ApiStatus.Experimental
//  class NewPullRequest internal constructor(
//    project: Project,
//    dataContext: GCPRDataContext
//  ) : GCPRToolWindowTabViewModel {
//    private val allRepos = project.service<GCHostedRepositoriesManager>().knownRepositories.map { it.repository }
//
//    override val displayName: String =
//      GitCodeBundle.message("tab.title.pull.requests.new",
//                           GCUIUtil.getRepositoryDisplayName(allRepos,
//                                                             dataContext.repositoryDataService.repositoryCoordinates))
//
//    private val _focusRequests = Channel<Unit>(1)
//    internal val focusRequests: Flow<Unit> = _focusRequests.receiveAsFlow()
//
//    fun requestFocus() {
//      _focusRequests.trySend(Unit)
//    }
//  }
//}
